function modifyPrice() {
    var price = isNAN($("#vip_price").val());
    if (price == 0) {
        swal("提示", "价格不得为0！", "error");
        return;
    }
    ajax("vip/modifyPrice", {"vip_price": price}, "text", "post", true, function (data) {
        switch (data) {
            case "success":
                swal({
                    title: "修改成功",
                    type: "success",
                    confirmButtonColor: "#9ACD32",
                    confirmButtonText: "OK",
                    closeOnConfirm: false
                }, function () {
                    window.location.reload();
                });
                /*swal("提示", "价格修改成功！", "success",function () {
                });*/
                break;
            case "fail":
                swal("提示", "修改失败,请稍后再试！", "error");
                break;
            default:
                swal("提示", "修改失败,请稍后再试！", "error");
                break;
        }
    }, function (error) {
        console.log(error);
        swal("提示", "修改时出现问题,请稍后再试！", "error");
    });
}


function modifyInterestRate() {
    var lilv = isNAN($("#lilv").val());
    if (lilv < 0 || lilv == 0) {
        swal("提示", "利率不得小于等于0！", "error");
        return;
    }
    ajax("interest_rate/modifyInterestRate", {"interest_rate": lilv}, "text", "post", true, function (data) {
        switch (data) {
            case "success":
                swal({
                    title: "修改成功",
                    type: "success",
                    confirmButtonColor: "#9ACD32",
                    confirmButtonText: "OK",
                    closeOnConfirm: false
                }, function () {
                    window.location.reload();
                });
                /*swal("提示", "价格修改成功！", "success",function () {
                });*/
                break;
            case "fail":
                swal("提示", "修改失败,请稍后再试！", "error");
                break;
            case "small":
                swal("提示", "利率必须大于0！", "error");
                break;
            case "error":
                swal("提示", "出现错误！", "error");
                break;
            default:
                swal("提示", "修改失败,请稍后再试！", "error");
                break;
        }
    }, function (error) {
        console.log(error);
        swal("提示", "修改时出现问题,请稍后再试！", "error");
    });
}



function modifyInvitationCode() {
    var code=$("#code").val();
    if (code.length==3){
        ajax("invitation_code/modify",{"code":code},"text","post",true,function (data) {
            switch (data) {
                case "success":
                    swal({
                        title: "修改成功",
                        type: "success",
                        confirmButtonColor: "#9ACD32",
                        confirmButtonText: "OK",
                        closeOnConfirm: false
                    }, function () {
                        window.location.reload();
                    });
                    break;
                case "fail":
                    swal("提示", "修改失败,请稍后再试！", "error");
                    break;
                case "length_restriction":
                    swal("提示", "邀请码长度必须为三位！", "error");
                    break;
                default :
                    swal("提示", "修改时出现问题,请稍后再试！", "error");
                    break;
            }
        },function (error) {
            console.log(error);
            swal("提示", "修改时出现问题,请稍后再试！", "error");
        });
    }else{
        swal("提示", "邀请码长度必须为三位！", "error");
    }
}




function loginOut() {
    swal({
        title: "确定退出?",
        text: "退出后未完成的工作将不会被保留！",
        type: "warning",
        showCancelButton: true,
        cancelButtonText: "取消",
        confirmButtonColor: "#DD6B55",
        confirmButtonText: "退出",
        closeOnConfirm: false
    }, function () {
        window.location.href = "admin/safeOut";
    });
}


//判断是否是数字
function isNAN(target) {
    return isNaN(parseInt(target)) ? 0 :target;
} 